﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using XLCS.Common;

namespace WPF_DbCenter.SqlServer.SomeFunctions
{
    /// <summary>
    /// Interaction logic for EnumSqlServer.xaml
    /// </summary>
    public partial class EnumSqlServer : Window
    {
        public event EventHandler SelectedSqlServer;

        public EnumSqlServer()
        {
            InitializeComponent();
            mySqlserverList.MouseDoubleClick += mySqlserverList_MouseDoubleClick;
        }

        void mySqlserverList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (mySqlserverList.SelectedItem != null)
            {
                string sqlName = mySqlserverList.SelectedItem.ToString();
                if (SelectedSqlServer != null)
                {
                    SelectedSqlServer(null, new MyEventArgs() {MyText=sqlName });
                }
                Close();
            }
        }

        private void butStartEnum_Click(object sender, RoutedEventArgs e)
        {
            mySqlserverList.DataContext = null;
            List<string> serverList=XLCS.Db.SqlLocator.GetServers().ToList();
            mySqlserverList.DataContext = serverList;


        }
    }
}
